package tms.util.activity;

import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@ApplicationScoped
public class UserActivityManager implements Serializable {
    private Map<Integer, Date> usersActivity;

    public void userActive(int userId) {
        usersActivity.put(userId, new Date());
    }

    public Date getLastActivityDate(int userId) {
        return usersActivity.get(userId);
    }

    @PostConstruct
    private void initActivityMap() {
        usersActivity = new ConcurrentHashMap<Integer, Date>();
    }
}
